<%@ page import="java.time.format.DateTimeFormatter" %>
<%@ page import="cas.client.User" %><%--
  Created by IntelliJ IDEA.
  User: 17722
  Date: 2024/4/21
  Time: 17:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>WebAPP1</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resource/MainPage/style.css" />
</head>
<body>
    <h1><%="尊敬的用户" + request.getAttribute("account") + "，欢迎来到WebAPP1。"%>
        <form style="display: inline" action="${pageContext.request.contextPath}/logout">
            <button type="submit" class="check-btn">注销登出</button>
        </form>
    </h1>
    <p>WebAPP1在线用户如下所示：</p>
    <ul class="draggable-list" id="draggable-list">
        <%
            User[] users = (User[]) request.getAttribute("users");
            for (int i = 0; i < users.length; ++i) {
                out.println("<li>");
                out.println("<span class=\"number\">" + (i + 1) + "</span>");
                out.println("<div class=\"draggable\" draggable=\"true\">");
                out.println("<p class=\"person-name\">" + "用户" + users[i].getAccount() + "</p>");
                out.println("<p class=\"person-name\">" + "上线于" + users[i].getLoginTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒")) + "</p>");
                out.println("</div>");
                out.println("</li>");
            }
        %>
    </ul>
    <p style="background-color: rgba(255,255,255,0.8)"><span>友情链接：<a href="http://localhost:8080">WebCAS</a> | <a href="http://localhost:8081">WebAPP1</a> | <a href="http://localhost:8082">WebAPP2</a></span></p>
    <script src="${pageContext.request.contextPath}/resource/MainPage/script.js"></script>
</body>
</html>
